package com.yibudong.found;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class InitUserInfoActiivty extends Activity {
	private static final String TAG = InitUserInfoActiivty.class.getSimpleName();

	private EditText mNickEditText;
	private RadioGroup mSexRadioGroup;
	
	private Button mStartButton;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.init_userinfo);
		
		mNickEditText = (EditText)findViewById(R.id.et_nick_setting);
		mNickEditText.addTextChangedListener(mTextWatcher);
		mSexRadioGroup = (RadioGroup)findViewById(R.id.radiogroup_sex);
		mSexRadioGroup.setOnCheckedChangeListener(mCheckedChangeListener);
		
		mStartButton = (Button)findViewById(R.id.btn_start_found);
		mStartButton.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(InitUserInfoActiivty.this, FoundActivity.class);
				startActivity(intent);
				finish();
			}});
	}
	
	private OnCheckedChangeListener mCheckedChangeListener = new OnCheckedChangeListener(){

		@Override
		public void onCheckedChanged(RadioGroup group, int checkedId) {
			
			
		}
	};
		
	private TextWatcher mTextWatcher = new TextWatcher(){

			@Override
			public void afterTextChanged(Editable s) {
				if(!TextUtils.isEmpty(s.toString()) && (-1 != mSexRadioGroup.getCheckedRadioButtonId())){
					mStartButton.setEnabled(true);
				}else{
					mStartButton.setEnabled(false);
				}
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				
			}

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				
			}};
	
}
